package com.example.chat.controller;

import com.dragonsoftbravo.libs.Opr;
import com.example.chat.model.Employee;
import com.example.chat.model.ro.EmployeeUpdateRO;
import com.example.chat.service.EmployeeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description
 * @Date 2022/11/17 17:21
 * @Author pq
 */
@Api(value = "员工管理", tags = {"员工管理"})
@RestController
@RequestMapping("/employee")
public class EmployeeController extends BaseController{

    @Resource
    private EmployeeService employeeService;


    @ApiOperation(value = "新增/更新员工")
    @PostMapping("/update")
    public ResponseEntity<Opr<Void>> updateEmployee(@Validated @RequestBody EmployeeUpdateRO employeeUpdateRO, BindingResult br){
        validateFiled(br);
        employeeService.updateEmployee(employeeUpdateRO);
        return this.process(this::successResult);
    }
}
